<?php 
namespace Common\Service\Pay;
use Common\ServiceInterface\PayService;
/**
 * 支付宝服务接口
 * @author liuyang
 *
 */ 
require_once("pay/alipay/lib/alipay_notify.class.php");

class AlipayService implements PayService{
   
        public  function getSignInfo($data,$alipay_config){ 
          $data['partner']=$alipay_config['partner'];
          $data['seller_id']=$alipay_config['seller_id'];
          $data['notify_url']=$alipay_config['notify_url'];
          $data['service']="mobile.securitypay.pay";
          $data['payment_type']="1";
          $data['it_b_pay']="30m";
          $data['_input_charset']="utf-8"; 
          $data['sign_type']="RSA";
          $data['show_url']="m.alipay.com"; 
          $alipayNotify = new \AlipayNotify($alipay_config);   
           //除去待签名参数数组中的空值和签名参数
          $para_filter = paraFilter($data); 
           //对待签名参数数组排序
          $para_sort = argSort($para_filter); 
           //把数组所有元素，按照“参数=参数值”的模式用“&”字符拼接成字符串
         $prestr = createLinkstring($para_sort);  
         $sign=rsaSign($prestr,$alipay_config['private_key_path']);    
        // $isSign=$alipayNotify->getSignVeryfy($data, $sign);  
          if($sign){
              $data['sign']=urlencode($sign); 
              $data['sign_type']="RSA";
              //对待签名参数数组排序
              $para_sort = argSort($data);
              
              //把数组所有元素，按照“参数=参数值”的模式用“&”字符拼接成字符串
              $prestr = createLinkstring($para_sort);
              $data['orderstr']=$prestr; 
              return $data;
          }else{
              return false;
          }
          
      }
	   
}